var myApp = angular.module("myApp", ["ui.router"
    , 'ngAnimate'
    , 'ui.bootstrap'
    , "ngFileUpload"
    , 'diff-match-patch'
    , 'ngMaterial'
    , 'uiSwitch'
    , 'ngSanitize'
    , 'ui.select'
    , 'ngDialog'
    , 'treeControl'], function ($httpProvider) {
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
    var param = function (obj) {
        var query = '', name, value, fullSubName, subName, subValue, innerObj, i;
        for (name in obj) {
            value = obj[name];
            if (value instanceof Array) {
                for (i = 0; i < value.length; ++i) {
                    subValue = value[i];
                    fullSubName = name + '[' + i + ']';
                    innerObj = {};
                    innerObj[fullSubName] = subValue;
                    query += param(innerObj) + '&';
                }
                ;
            } else if (value instanceof Object) {
                for (subName in value) {
                    subValue = value[subName];
                    fullSubName = name + '[' + subName + ']';
                    innerObj = {};
                    innerObj[fullSubName] = subValue;
                    query += param(innerObj) + '&';
                }
                ;
            } else if (value !== undefined && value !== null)
                query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&';
        }
        ;
        return query.length ? query.substr(0, query.length - 1) : query;
    };
    $httpProvider.defaults.transformRequest = [function (data) {
        return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
    }];
});

myApp.config(function ($stateProvider, $urlRouterProvider, $mdThemingProvider, $rootScopeProvider, ngDialogProvider) {

    $urlRouterProvider.when("", "/menu");

    function getTemplateUrl(url) {
        return url + "?" + new Date().getTime();
    }

    $stateProvider
        .state("menu", {
            url: "/menu",
            templateUrl: getTemplateUrl("/beetle/App/module/menu/tpl/menu.html"),
            controller: "MenuController"
        }).state("menu.jumpServerList", {
        url: "/jumpServerList",
        templateUrl: getTemplateUrl("/beetle/App/module/jumpServer/tpl/list.html"),
        controller: "JumpServerController"
    }).state("menu.editJumpServer", {
        url: "/editJumpServer/:type/:selectServer",
        templateUrl: getTemplateUrl("/beetle/App/module/jumpServer/tpl/edit.html"),
        controller: "EditJumpServerController"
    }).state("menu.pushRecord", {
        url: "/pushRecord",
        templateUrl: getTemplateUrl("/beetle/App/module/pushRecord/tpl/list.html"),
        controller: "PushRecordController"
    }).state("menu.projectSet", {
        url: "/projectSet/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/project/tpl/projectList.html"),
        controller: "ProjectListController"
    }).state("menu.projectEdit", {
        url: "/projectEdit/:projectName/:isTrunk/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/project/tpl/projectEdit.html"),
        controller: "ProjectEditController"
    }).state("menu.userList", {
        url: "/userList/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/user/tpl/userList.html"),
        controller: "UserListController"
    }).state("menu.roleList", {
        url: "/roleList/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/user/tpl/roleList.html"),
        controller: "roleListController"
    }).state("menu.roleAdd", {
        url: "/roleAdd/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/user/tpl/roleAdd.html"),
        controller: "roleAddController"
    }).state("menu.userAdd", {
        url: "/userAdd/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/user/tpl/userAdd.html"),
        controller: "UserAddController"
    }).state("menu.userUpdate", {
        url: "/userUpdate/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/user/tpl/passUpdate.html"),
        controller: "PassUpdateController"
    }).state("menu.new_menu", {
        url: "/menu/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/menu/tpl/menuSet.html"),
        controller: "MenuSetController"
    }).state("menu.configFile", {
        url: "/configFile/:selectProject/:selectFile/:selectEnv/:filterConfig",
        templateUrl: getTemplateUrl("/beetle/App/module/resource/tpl/configFile.html"),
        controller: "ConfigFileController"
    }).state("menu.deploy", {
        url: "/deploy",
        templateUrl: getTemplateUrl("/beetle/App/module/hotDeployment/tpl/deploy.html"),
        controller: "DeployController"
    }).state("menu.serverConfig", {
        url: "/serverConfig",
        templateUrl: getTemplateUrl("/beetle/App/module/hotDeployment/tpl/serverConfig.html"),
        controller: "ServerConfigController"
    }).state("menu.project", {
        url: "/project/:selectProject",
        templateUrl: getTemplateUrl("/beetle/App/module/project/tpl/project.html"),
        controller: "ProjectController"
    }).state("menu.ucList", {
        url: "/ucList",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/ucList.html"),
        controller: "UCListController"
    }).state("menu.ucProgress", {
        url: "/ucProgress/:selectVm",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/ucProgress.html"),
        controller: "UCProgressController"
    }).state("menu.ucRelease", {
        url: "/ucRelease/:selectVm",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/ucRelease.html"),
        controller: "UCReleaseController"
    }).state("menu.ucInit", {
        url: "/ucInit/:selectVm",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/ucInit.html"),
        controller: "UCInitController"
    }).state("menu.ucAlylist", {
        url: "/ucAlylist/:plan_name",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/ucAlylist.html"),
        controller: "ucAlylistController"
    }).state("menu.newucRelease", {
        url: "/newucRelease/:ip/:plan_name/:id/:plan_id",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/newucRelease.html"),
        controller: "newucReleaseController"
    }).state("menu.newucList", {
        url: "/newucList/:agent_ip",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/newucList.html"),
        controller: "newuclistController"
    }).state("menu.plan_Guide", {
        url: "/plan_Guide/:type",
        templateUrl: getTemplateUrl("/beetle/App/module/planProject/tpl/plan_Guide.html"),
        controller: "plan_GuideController"
    }).state("menu.planList", {
        url: "/planList/",
        templateUrl: getTemplateUrl("/beetle/App/module/planProject/tpl/planList.html"),
        controller: "planListController"
    }).state("menu.plan_ProjectList", {
        url: "/plan_ProjectList/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/planProject/tpl/plan_ProjectList.html"),
        controller: "plan_ProjectListController"
    }).state("menu.integrationList", {
        url: "/integration/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/integration/tpl/list.html"),
        controller: "IntegrationListController"
    }).state("menu.integrationInit", {
        url: "/integrationInit/:selectIntegration",
        templateUrl: getTemplateUrl("/beetle/App/module/integration/tpl/init.html"),
        controller: "IntegrationInitController"
    }).state("menu.integrationSet", {
        url: "/integrationSet/:selectIntegration",
        templateUrl: getTemplateUrl("/beetle/App/module/integration/tpl/set.html"),
        controller: "IntegrationSetController"
    }).state("menu.emergencyList", {
        url: "/emergencyList/",
        templateUrl: getTemplateUrl("/beetle/App/module/emergencyPlan/tpl/list.html"),
        controller: "EmergencyListController"
    }).state("menu.emergencyInfo", {
        url: "/emergencyInfo/:id",
        templateUrl: getTemplateUrl("/beetle/App/module/emergencyPlan/tpl/info.html"),
        controller: "EmergencyInfoController"
    }).state("menu.barrier", {
        url: "/barrier/",
        templateUrl: getTemplateUrl("/beetle/App/module/uBarrier/tpl/barrier.html"),
        controller: "barrierController"
    }).state("menu.ubarrierAuto", {
        url: "/ubarrierAuto/",
        templateUrl: getTemplateUrl("/beetle/App/module/uBarrier/tpl/ubarrierAuto.html"),
        controller: "ubarrierAutoController"
    }).state("menu.authorizeC", {
        url: "/authorizeC/",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/authorizeC.html"),
        controller: "AuthorizeCController"
    }).state("menu.uTest", {
        url: "/uTest/",
        templateUrl: getTemplateUrl("/beetle/App/module/uTest/tpl/uTest.html"),
        controller: "uTestController"
    }).state("menu.uTestRecord", {
        url: "/uTestRecord/",
        templateUrl: getTemplateUrl("/beetle/App/module/uTest/tpl/Record.html"),
        controller: "RecordController"
    }).state("menu.addZoneAndApp", {
        url: "/addZoneAndApp/",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/addZoneAndApp.html"),
        controller: "addZoneAndAppController"
    }).state("menu.zalist", {
        url: "/zalist/",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/zalist.html"),
        controller: "zalistController"
    }).state("menu.machinelist", {
        url: "/machinelist/",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/machinelist.html"),
        controller: "machinelistController"
    }).state("menu.addMachine", {
        url: "/addMachine/",
        templateUrl: getTemplateUrl("/beetle/App/module/uCloud/tpl/addMachine.html"),
        controller: "addMachineController"
    }).state("menu.urllist", {
        url: "/urllist/",
        templateUrl: getTemplateUrl("/beetle/App/module/common/tpl/urllist.html"),
        controller: "urllistController"
    }).state("menu.prodexport", {
        url: "/prodexport/",
        templateUrl: getTemplateUrl("/beetle/App/module/prod/tpl/export.html"),
        controller: "ProdExportController"
    }).state("menu.prodclean", {
        url: "/prodclean/",
        templateUrl: getTemplateUrl("/beetle/App/module/prod/tpl/clean.html"),
        controller: "ProdCleanController"
    });

    // for angular diff.
    $mdThemingProvider.theme('default')
        .primaryPalette('indigo')
        .accentPalette('blue');

    $rootScopeProvider.digestTtl(20);

    ngDialogProvider.setDefaults({
        className: 'ngdialog-theme-default',
        closeByEscape: false,
        showClose: false,
        closeByDocument: false
    });
});
myApp.directive('toggle', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            if (attrs.toggle == "tooltip") {
                $(element).tooltip(attrs);
            }
            if (attrs.toggle == "popover") {
                $(element).popover();
            }
        }
    };
}).directive('popover', function () {
    return {
        restrict: 'A',
        scope: {
            popoverShow: '=',
            popoverOptions: '@'
        },
        link: function (scope, element) {
            element = $(element);
            var options = {
                "template": '<div class="popover" style="max-width:500px;" role="tooltip">' +
                    '<div class="arrow"></div>' +
                    '<div class="popover-content" style="padding:2px 14px"></div>' +
                    '</div>',
                "placement": "right",
                "trigger": "manual",
                "html": true,
                "content": '<font color="red">' + scope.popoverOptions + '</font>'
            };
            element.popover(options);

            element.on('blur', function () {
                if (scope.popoverShow) {
                    element.popover('show');
                }
            });

            element.on('click', function () {
                element.popover('hide');
            });
            scope.$watch('popoverShow', function (show) {
                if (show) {
                    element.popover('show');
                } else {
                    element.popover('hide');
                }
            });
        }
    };
}).directive('validPop', function ($timeout) {
    return {
        restrict: 'A',
        scope: {
            validPopShow: '=',
            validPopOptions: '@',
            checkRepeatShow: '=',
            checkRepeatOptions: '@',
            placement: '@'
        },
        link: function (scope, element) {
            element = $(element);

            var getMsgContent = function () {
                return function () {
                    return '<font color="red">' + (scope.validPopShow ? scope.validPopOptions : scope.checkRepeatOptions) + '</font>';
                }
            };
            var placement = scope.placement && scope.placement != '' ? scope.placement : 'bottom';
            var options = {
                "template": '<div class="popover" style="max-width:500px;" role="tooltip">' +
                    '<div class="arrow"></div>' +
                    '<div class="popover-content" style="padding:2px 14px"></div>' +
                    '</div>',
                "placement": placement,
                "trigger": "manual",
                "html": true,
                "content": getMsgContent()
            };
            element.popover(options);

            element.on('blur', function () {
                if (scope.validPopShow || scope.checkRepeatShow) {
                    element.popover('show');
                }
            });
            scope.$watch('validPopShow', function (show) {
                if (show || scope.checkRepeatShow) {
                    element.popover('show');
                } else {
                    element.popover('hide');
                }
            });
            scope.$watch('checkRepeatShow', function (show) {
                if (show || scope.validPopShow) {
                    element.popover('show');
                } else {
                    element.popover('hide');
                }
            });

            element.on('click', function () {
                element.popover('hide');
            });
        }
    };
}).directive('convertToNumber', function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attrs, ngModel) {
            ngModel.$parsers.push(function (val) {
                return parseInt(val, 10);
            });
            ngModel.$formatters.push(function (val) {
                return '' + val;
            });
        }
    };
}).directive('logDiv', function ($compile, $parse) {
    return {
        restrict: 'E',
        link: function (scope, element, attr) {
            scope.$watch(attr.content, function () {
                element.html($parse(attr.content)(scope));
                $compile(element.contents())(scope);
            }, true);
        }
    }
});

myApp.filter('paging', function () {

    return function (list, index, pageSize) {

        if (!list)

            return [];


        var offset = (index - 1) * pageSize;

        return list.slice(offset, offset + pageSize);

    }

});

myApp.filter('size', function () {

    return function (list) {

        if (!list)

            return 0;


        return list.length || 0

    }

});
//2017-04-25T00:37:56+00:00
myApp.filter('create_date_filter', function () {
    return function (date) {
        if (!date)
            return '';
        return date.replace('T', ' ').substring(0, 19);
    }
});
myApp.filter('split_filter', function () {
    return function (str, symbol, index) {
        return str.split(symbol)[index];
    }
});
myApp.focus = function () {
    if (myApp.onfocus) {
        myApp.onfocus();
    }
};
myApp.run(function ($rootScope, $uibModal, $http) {
    //定义一个全局函数
    $rootScope.isUserCanOperateByRole = function () {
        if (arguments.length == 0) {
            return isUserCanOperateByRole();
        }
        var flag = false;

        for (var i = 0; i < arguments.length; i++) {
            if (isUserCanOperateByRole(arguments[i])) {
                flag = true;
            }
        }
        return flag;
    };
    $rootScope.isUserHasRole = function (role) {
        var userRole = getUserRole();
        return arrayContains(userRole, role);
    };
    $rootScope.arrayContains = function (array, obj) {
        return arrayContains(array, obj);
    };
    $rootScope.showGoBack = function (key) {
        var value = getStorage(key);
        if (value != '') {
            return true;
        } else {
            return false;
        }
    };
    $rootScope.goBack = function (key) {
        if (key) {
            var value = getStorage(key);
            if (value != '') {
                window.location.href = value;
            } else {
                window.history.back();
            }
        } else {
            window.history.back();
        }
    };
    $rootScope.canUpdateRole = function (role) {
        var roles = ['admin', 'audit', 'assign', 'pm', 'authorize', 'ucloud_admin', 'user_admin', 'plan_admin'];
        if (!isUserCanOperateByRole('user_admin')) {
            return false;
        }
        if (arrayContains(roles, role.role_name) && !isUserCanOperateByRole()) {
            return false;
        }
        return true;
    };
    /**
     * 提交测试通过弹窗
     * @param projectName 工程名
     * @param type 类型 提交测试(TEST)/转测(INTEGRATION)
     * @param saveFun 点击保存后调用的方法
     * @param closeFun 点击关闭后点用的方法
     * 调用方法
     *  $rootScope.editionToTestTemplate($scope.info,function () {
            console.log("save")
        },function () {
            console.log("close")
        });
     */
    $rootScope.editionToTestTemplate = function (projectName, type, saveFun, closeFun) {
        if (projectName == null || projectName == '') {
            alert("参数projectName错误!");
            return
        }
        if (type != 'TEST' && type != 'INTEGRATION') {
            alert("参数type错误!");
            return
        }
        var info = {};
        info.projectName = projectName;
        info.type = type;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'editionToTestTemplate.html',
            controller: 'EditionToTestTemplateCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun(reason);
                }
            });
    };
    /**
     * 批准集成 集成测试 功能测试弹窗
     * @param projectName 工程名
     * @param type 类型 功能测试(TEST)/集成测试(INTEGRATION)/批准集成(CAN_INTEGRATION)
     * @param saveFun 操作成功后调用的方法
     * @param closeFun 点击关闭后点用的方法
     * 调用方法
     *  $rootScope.editionIntegrationTemplate($scope.info,function () {
            console.log("save")
        },function () {
            console.log("close")
        });
     */
    $rootScope.editionIntegrationTemplate = function (projectName, type, saveFun, closeFun) {
        if (projectName == null || projectName == '') {
            alert("参数projectName错误!");
            return
        }
        if (type != 'TEST' && type != 'INTEGRATION' && type != 'CAN_INTEGRATION' && type != 'SEARCH') {
            alert("参数type错误!");
            return
        }
        var info = {};
        info.projectName = projectName;
        info.type = type;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'editionIntegrationTemplate.html',
            controller: 'EditionIntegrationTemplateCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun(reason);
                }
            });
    };
    /**
     * 为项目添加工程
     * @param planId  项目id
     * @param saveFun
     * @param closeFun
     */
    $rootScope.addPlanProjectTemplate = function (planId, saveFun, closeFun) {
        var info = {};
        info.planId = planId;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'addPlanProject.html',
            controller: 'AddPlanProjectCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun();
                }
            });
    };
    $rootScope.changePlanProjectTemplate = function (planId, trunkName, saveFun, closeFun) {
        var info = {};
        info.planId = planId;
        info.trunkName = trunkName;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'changePlanProject.html',
            controller: 'ChangePlanProjectCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun();
                }
            });
    };
    $rootScope.toIntegrationSet = function (integration_name) {
        window.location.href = '#/menu/integrationSet/' + integration_name;
    };
    $rootScope.getStatusDesc = function (status) {
        var desc = status;
        if (status == 'INT_NOT_START') {
            desc = "未开始";
        } else if (status == 'INTEGRATIONING') {
            desc = "集成测试中";
        } else if (status == 'HAND_OVER') {
            desc = "已交付运维";
        } else if (status == "ONLINE") {
            desc = "已上线";
        } else if (status == "PRO_NOT_CREATE") {
            desc = "未创建";
        } else if (status == "PRO_CREATED") {
            desc = "创建成功";
        } else if (status == "PRO_CREATE_ERROR") {
            desc = "创建失败";
        } else if (status == "PRO_DEVELOPING") {
            desc = "开发中";
        } else if (status == "PRO_TESTING") {
            desc = "测试中";
        } else if (status == "PRO_MERGED") {
            desc = "被合并";
        } else if (status == "TO_INTEGRATION") {
            desc = "交付集成";
        } else if (status == "BE_CANCEL") {
            desc = "被撤下";
        } else if (status == "PLAN_NEW") {
            desc = "新建项目";
        }
        return desc;
    };
    $rootScope.getOperateDesc = function (status) {
        var desc = status;
        if (status == 'to_test') {
            desc = "提交功能测试";
        } else if (status == 'cancel_to_test') {
            desc = "取消功能提测";
        } else if (status == 'test') {
            desc = "开始功能测试";
        } else if (status == "cancel_test") {
            desc = "取消功能测试";
        } else if (status == 'to_integration') {
            desc = "提交集成测试";
        } else if (status == 'cancel_to_integration') {
            desc = "取消集成提测";
        } else if (status == 'can_integration') {
            desc = "可以进入集成";
        } else if (status == 'can_not_integration') {
            desc = "不可以进入集成";
        } else if (status == 'integration') {
            desc = "开始集成测试";
        } else if (status == 'cancel_integration') {
            desc = "取消集成测试";
        } else if (status == 'hand_over') {
            desc = "交付运维";
        } else if (status == 'cancel_hand_over') {
            desc = "取消交付运维";
        } else if (status == 'online') {
            desc = "上线";
        } else if (status == 'change_branch') {
            desc = "切换工程分支";
        }
        return desc;
    };
    $rootScope.checkAlertTemplate = function (dialogHtml, msg, saveFun, closeFun) {
        var info = {};
        info.msg = msg;
        info.check = false;
        info.dialogHtml = dialogHtml;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'checkAlert.html',
            controller: 'CheckAlertCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun(reason);
                }
            });
    };
    $rootScope.FileUploadTemplate = function (uploadUrl, allowedFileExtensions, data, showDir, saveFun, closeFun) {
        var info = {};
        info.uploadUrl = uploadUrl;
        info.allowedFileExtensions = allowedFileExtensions;
        info.data = data;
        info.showDir = showDir;
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'fileUpload.html',
            controller: 'FileUploadCtrl',
            keyboard: false,
            backdrop: 'static',
            resolve: {
                info: function () {
                    return info;
                }
            }
        });
        modalInstance.result.then(function (result) {
                if (closeFun) {
                    closeFun();
                }
            },
            function (reason) {
                if (saveFun) {
                    saveFun();
                }
            });
    };
    $rootScope.$on('$stateChangeStart', function (e, toState, toParams, fromState, fromParams) {
        var tokenId = getTokenId();
        if ('' == tokenId) {
            e.preventDefault();
            setStorage("to_state", toState);
            setStorage("to_params", toParams);
            window.location.href = "/beetle/App/module/login/tpl/login.html";
            return;
        }

        if (getUserAccount() != '') {
            return;
        }

        $http.get(python_url + '/api/v1/login/info?token_id=' + getTokenId(), {}).success(function (data) {
            if (data.success == false) {
                e.preventDefault();
                setStorage("to_state", toState);
                setStorage("to_params", toParams);
                window.location.href = "/beetle/App/module/login/tpl/login.html";
                return;
            }
            ;
            var rolelist_name = [];
            var rolelist_id = [];
            angular.forEach(data.data.role_list, function (list) {
                rolelist_name.push(list.role_name);
                rolelist_id.push(list.role_id);
            });
            setUserName(data.data.realname);
            setUserRole(rolelist_name);
            setUserId(data.data.id);
            setUserAccount(data.data.account);
        });
    });
});
